/* ====================================================================
 * (#)Header: Encryptor.java
 * (#)Revision: 
 * (#)Date Created: Jul 15, 2009 11:34:23 PM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */

package com.karolak.security;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * This class is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class Encryptor {

	public static String digest(String algorithm, String message) {
		MessageDigest digest = null;
		try {
			digest = MessageDigest.getInstance(algorithm);
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		}
		digest.update(message.getBytes());
		byte[] hash = digest.digest();
		digest.reset();
		String str = new String(hash);
		return str;
	}
}
